package com.billsharing.server;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.google.gson.JsonObject;

import net.sf.json.JSONObject;

/**
 * Servlet implementation class AddGroup
 */
@WebServlet("/AddGroup")
public class AddGroup extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
  

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	
	{
		// TODO Auto-generated method stub
		

	PrintWriter out = response.getWriter();
	int	uid = Integer.parseInt(request.getParameter("uid"));
	String	grp_name = request.getParameter("gname");
	System.out.println("User in add Group"+uid);
	try
	{
	Group grp=new Group(grp_name,uid);
	JSONObject json = new JSONObject();
	json.put("gid", grp.getGid());
	json.put("groupName",grp.getGroupName());
	
	out.print(json);
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
	
	}	
	}


